//
//  LXVisitorTableViewController.swift
//  weibo
//
//  Created by lixin on 16/4/16.
//  Copyright © 2016年 lixin. All rights reserved.
//

import UIKit

class LXVisitorTableViewController: UITableViewController {
    
    var isLogin:Bool = LXUserAccountTools.sharedTools.isLogin
    
    var visitorView:LXVisitorView?
    
    override func loadView() {
        
        isLogin ? super.loadView() : setUpVisitorView()
    }

    override func viewDidLoad() {
        super.viewDidLoad()

    }
    
    //MARK: - 登录事件
    @objc private func login(){
    
        let oauthVc = LXOAuthViewController()
        
        presentViewController(UINavigationController(rootViewController:oauthVc), animated: true, completion: nil)
    }
    
    //MARK: - 设置导航栏
    private func setUpNav(){
    
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: #selector(LXVisitorTableViewController.login))
        
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: #selector(LXVisitorTableViewController.login))
    }
    
    //MARK: - 设置视图
    private func setUpVisitorView(){
    
        setUpNav()
        
        visitorView = LXVisitorView()
        
        visitorView?.visitorClosure = {
        
            self.login()
        }
        
        view = visitorView
    }

}
